<?php

namespace app\api\validate;
use app\common\validate\BaseValidate;

class Goods extends BaseValidate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	         =>	['规则1','规则2'...]
     *
     * @var array
     */	
    protected $rule = [
        'book_id'                 => 'require|isNotEmpty',
        'book_name'               => 'require|isNotEmpty|length:2,32',
        'book_status'             => 'require|isNotEmpty',
        'book_img'                => 'require|isNotEmpty',
        'book_isbn'               => 'require|isNotEmpty',
        'author'                  => 'require|isNotEmpty',
        'library_ids'             => 'require|isNotEmpty',
        'layer_ids'               => 'require|isNotEmpty|isArray',
        'count'                  => 'require|isNotEmpty',
        'press'                  => 'require|isNotEmpty',
        'pages'                 => 'require|isNotEmpty',
        'book_category'          => 'require|isNotEmpty',
        'introduce'          => 'require|isNotEmpty',
        'borrowing_status'          => 'require|isNotEmpty',

    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	           =>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'book_id.require' => '书籍名称id不能为空',
        'book_name.require' => '书籍名称名称不能为空',
        'book_status.require' => '书籍名称状态是必须的且不能为空',
        'book_code.require' => '条码不能为空',
        'book_floor.require' => '楼层不能为空',
        'book_area.require' => '区域不能为空',
        'library_ids.require' => '所属藏馆不能为空',
        'borrowing_status.require' => '借阅状态不能为空',
        'library_ids.isArray' => '所属藏馆必须是array数组数据',
        'book_category.require' => '图书分类不能为空',
        'book_category.isArray' => '图书分类必须是array数组数据',
        'layer_ids.require' => '层架不能为空',
        'layer_ids.isArray' => '层架必须是array数组数据',
    ];

   

    protected $scene = [
        'save'   => ['book_name', 'book_code', 'book_floor', 'book_area', 'layer_ids', 'book_category', 'library_ids'],
        'update' => ['book_id', 'book_name', 'book_code', 'book_floor', 'book_area', 'layer_ids', 'book_category', 'library_ids'],
        'delete' => ['book_id'],
        'status' => ['book_id'],
    ];
}
